package com.probiz.estore.common.model.system.base;

import java.io.Serializable;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * AppRole Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AppRoleTbl extends BaseObject implements Serializable {

    protected Integer roleId;
	protected String roleName;
	protected String roleDetail;
	protected String rolePath;
	protected Short belongTo;
	protected Short isSystem;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Integer version;
	protected com.probiz.estore.common.model.system.AppRole appRole;

	protected java.util.Set appMenus = new java.util.HashSet();
	protected java.util.Set appResources = new java.util.HashSet();
	protected java.util.Set appRoles = new java.util.HashSet();
	protected java.util.Set appUsers = new java.util.HashSet();
	protected java.util.Set appMemberships = new java.util.HashSet();
	/**
	 * Default Empty Constructor for class AppRole
	 */
	public AppRoleTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class AppRole
	 */
	public AppRoleTbl (
		 Integer in_roleId
        ) {
		this.setRoleId(in_roleId);
    }

	
	public com.probiz.estore.common.model.system.AppRole getAppRole () {
		return appRole;
	}	
	
	public void setAppRole (com.probiz.estore.common.model.system.AppRole in_appRole) {
		this.appRole = in_appRole;
	}

	public java.util.Set getAppMenus () {
		return appMenus;
	}	
	
	public void setAppMenus (java.util.Set in_appMenus) {
		this.appMenus = in_appMenus;
	}

	public java.util.Set getAppResources () {
		return appResources;
	}	
	
	public void setAppResources (java.util.Set in_appResources) {
		this.appResources = in_appResources;
	}

	public java.util.Set getAppUsers() {
		return appUsers;
	}

	public void setAppUsers(java.util.Set appUsers) {
		this.appUsers = appUsers;
	}

	public java.util.Set getAppMemberships() {
		return appMemberships;
	}

	public void setAppMemberships(java.util.Set appMemberships) {
		this.appMemberships = appMemberships;
	}

	public java.util.Set getAppRoles () {
		return appRoles;
	}	
	
	public void setAppRoles (java.util.Set in_appRoles) {
		this.appRoles = in_appRoles;
	}

	/**
	 * 	 * @return Integer
     * @hibernate.id column="roleId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getRoleId() {
		return this.roleId;
	}
	
	/**
	 * Set the roleId
	 */	
	public void setRoleId(Integer aValue) {
		this.roleId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getParentId() {
		return this.getAppRole()==null?null:this.getAppRole().getParentId();
	}
	
	/**
	 * Set the parentId
	 */	
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	appRole = null;
	    } else {
	        appRole = new com.probiz.estore.common.model.system.AppRole(aValue);
	        appRole.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="roleName" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getRoleName() {
		return this.roleName;
	}
	
	/**
	 * Set the roleName
	 * @spring.validator type="required"
	 */	
	public void setRoleName(String aValue) {
		this.roleName = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="roleDetail" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getRoleDetail() {
		return this.roleDetail;
	}
	
	/**
	 * Set the roleDetail
	 */	
	public void setRoleDetail(String aValue) {
		this.roleDetail = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="rolePath" type="java.lang.String" length="512" not-null="false" unique="false"
	 */
	public String getRolePath() {
		return this.rolePath;
	}
	
	/**
	 * Set the rolePath
	 */	
	public void setRolePath(String aValue) {
		this.rolePath = aValue;
	}	

	/**
	 * 0-后台角色 1-前台角色	 * @return Short
	 * @hibernate.property column="belongTo" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getBelongTo() {
		return this.belongTo;
	}
	
	/**
	 * Set the belongTo
	 * @spring.validator type="required"
	 */	
	public void setBelongTo(Short aValue) {
		this.belongTo = aValue;
	}	

	/**
	 * 是否系统初始化的	 * @return Short
	 * @hibernate.property column="isSystem" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getIsSystem() {
		return this.isSystem;
	}
	
	/**
	 * Set the isSystem
	 * @spring.validator type="required"
	 */	
	public void setIsSystem(Short aValue) {
		this.isSystem = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof AppRoleTbl)) {
			return false;
		}
		AppRoleTbl rhs = (AppRoleTbl) object;
		return new EqualsBuilder()
				.append(this.roleId, rhs.roleId)
						.append(this.roleName, rhs.roleName)
				.append(this.roleDetail, rhs.roleDetail)
				.append(this.rolePath, rhs.rolePath)
				.append(this.belongTo, rhs.belongTo)
				.append(this.isSystem, rhs.isSystem)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.roleId) 
						.append(this.roleName) 
				.append(this.roleDetail) 
				.append(this.rolePath) 
				.append(this.belongTo) 
				.append(this.isSystem) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("roleId", this.roleId) 
						.append("roleName", this.roleName) 
				.append("roleDetail", this.roleDetail) 
				.append("rolePath", this.rolePath) 
				.append("belongTo", this.belongTo) 
				.append("isSystem", this.isSystem) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "roleId";
	}
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return roleId;
	}

}